From b253aca883e886a5b5b8eaa770594ad1b77e9afe Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 19 Mar 2021 14:30:19 -0400 Subject: [PATCH] ngl: Improve the glyph front cache The effectiveness of the front cache is limited by subpixel positioning making it very likely that we will meet the same glyph in different x phases inside a single line of text. Factoring the xphase into the front cache key makes things better. For the string eeeeeeeeeeeeeeeeeee before: 0% front cache hits after: >90% front cache hits --- gsk/ngl/gsknglglyphlibraryprivate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/ngl/gsknglglyphlibraryprivate.h b/gsk/ngl/gsknglglyphlibraryprivate.h index f48ae6e585..c44068dd50 100644 --- a/gsk/ngl/gsknglglyphlibraryprivate.h +++ b/gsk/ngl/gsknglglyphlibraryprivate.h @@ -91,7 +91,7 @@ gsk_ngl_glyph_library_lookup_or_add (GskNglGlyphLibrary *self, const GskNglGlyphValue **out_value) { GskNglTextureAtlasEntry *entry; - guint front_index = key->glyph & 0xFF; + guint front_index = ((key->glyph << 2) | key->xshift) & 0xFF; if (memcmp (key, &self->front[front_index], sizeof *key) == 0) { -- 2.30.2